package com.bondex.charter.controller;

import com.bondex.charter.po.CharterBooking;
import com.bondex.charter.pojo.DetailPageOutT;
import com.bondex.charter.pojo.SearchParam;
import com.bondex.charter.service.BookingService;
import com.bondex.global.pojo.PageTableParamT;
import com.bondex.global.pojo.ResultT;
import com.bondex.viresult.dto.BookingReleaseDTO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Booking订舱页面相关接口
 * Created by JD on 2021/09/14.
 */
@Controller
@RequestMapping("/Booking")
@Tag(name = "Booking")
public class BookingController extends BaseController {

    @Autowired
    private BookingService bookingService;

    @Operation(summary = "页面信息查询")
    @RequestMapping(value = "/getInfo", method = RequestMethod.POST)
    @ResponseBody
    public ResultT<DetailPageOutT<CharterBooking, CharterBooking>> getInfo(HttpServletRequest request, HttpServletResponse response
            , @Parameter(description = "委托单号（包船业务流水号）") @RequestParam(value = "orderNo") String orderNo
    ) {
        ResultT<DetailPageOutT<CharterBooking, CharterBooking>> oResult = bookingService.getInfo(orderNo);
        return oResult;
    }

    @Operation(summary = "订舱保存")
    @RequestMapping(value = "/saveInfo", method = RequestMethod.POST)
    @ResponseBody
    public ResultT saveInfo(HttpServletRequest request, @Parameter(description = "保存入参") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.saveBookingInfo(bookingReleaseDTO);
    }

    @Operation(summary = "放舱")
    @RequestMapping(value = "/releaseShippingSpaceForDetail", method = RequestMethod.POST)
    @ResponseBody
    public ResultT releaseShippingSpaceForDetail(HttpServletRequest request, @Parameter(description = "放舱入参") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.releaseShippingSpaceForDetail(bookingReleaseDTO);
    }
    @Operation(summary = "台账放舱")
    @RequestMapping(value = "/releaseShippingSpace", method = RequestMethod.POST)
    @ResponseBody
    public ResultT releaseShippingSpace(HttpServletRequest request, @Parameter(description = "台账放舱入参") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.releaseShippingSpace(bookingReleaseDTO);
    }

    @Operation(summary = "拒绝订舱")
    @RequestMapping(value = "/refuseBookingDetail", method = RequestMethod.POST)
    @ResponseBody
    public ResultT refuseBookingDetail(HttpServletRequest request, @Parameter(description = "拒绝订舱入参") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.refuseBookingDetail(bookingReleaseDTO);
    }
    @Operation(summary = "台账拒绝订舱")
    @RequestMapping(value = "/refuseBooking", method = RequestMethod.POST)
    @ResponseBody
    public ResultT refuseBooking(HttpServletRequest request, @Parameter(description = "台账拒绝订舱入参") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.refuseBooking(bookingReleaseDTO);
    }

    @Operation(summary = "退舱")
    @RequestMapping(value = "/disembarkBookingForDetail", method = RequestMethod.POST)
    @ResponseBody
    public ResultT disembarkBookingForDetail(HttpServletRequest request, @Parameter(description = "退舱") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.disembarkBookingForDetail(bookingReleaseDTO);
    }
    @Operation(summary = "台账退舱")
    @RequestMapping(value = "/disembarkBooking", method = RequestMethod.POST)
    @ResponseBody
    public ResultT disembarkBooking(HttpServletRequest request, @Parameter(description = "台账退舱") @RequestBody BookingReleaseDTO bookingReleaseDTO) {
        return bookingService.disembarkBooking(bookingReleaseDTO);
    }

    @Operation(summary = "历史操作")
    @RequestMapping(value = "/getHistoryInfo", method = RequestMethod.POST)
    @ResponseBody
    public String getHistoryInfo(HttpServletRequest request, HttpServletResponse response
            , @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
    ) {
        return "";
    }

    @Operation(summary = "历史状态")
    @RequestMapping(value = "/getHistoryStatus", method = RequestMethod.POST)
    @ResponseBody
    public String getHistoryStatus(HttpServletRequest request, HttpServletResponse response
            , @Parameter(description = "查询条件") PageTableParamT<SearchParam> param
    ) {
        return "";
    }

}